home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 6.4 KB | 225 lines | [TEXT/MPS ] |
- // UDebug.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UDEBUG__
- #define __UDEBUG__
-
- // MacApp
-
- #ifndef __MACAPPTYPES__
- #include "MacAppTypes.h"
- #endif
-
- #ifndef __UCLASSDESC__
- #include "UClassDesc.h"
- #endif
-
- #ifndef __UITERATOR__
- #include "UIterator.h"
- #endif
-
- // Toolbox
-
- // ANSI
-
- #ifndef __STDDEF__
- #include <stddef.h>
- #endif
-
- //----------------------------------------------------------------------------------------
- // Forward class declarations
- //----------------------------------------------------------------------------------------
-
- class CStackFrame;
- class TObject;
-
-
- //----------------------------------------------------------------------------------------
- // Procedure pointer typedefs
- //----------------------------------------------------------------------------------------
-
- typedef void (*DoToFrameType)(const CStackFrame& frame, void* yourDataPtr);
-
- #if qDebug
-
- //----------------------------------------------------------------------------------------
- // class CStackFrame
- //----------------------------------------------------------------------------------------
-
- class CStackFrame
- {
- private: // data fields
- ptrdiff_t fFramePtr;
-
- public: // methods
- CStackFrame(void* framePtr);
- CStackFrame(void);
- CStackFrame(ptrdiff_t framePtr);
-
- CStackFrame GetCallersStackFrame() const;
-
- void* GetReturnAddress() const;
-
- const ptrdiff_t GetStackFramePtr() const;
- const ptrdiff_t GetParametersPtr() const;
- const short& GetParameterWord(short nthWord) const;
- const long& GetParameterDoubleWord(short nthDoubleWord) const;
-
- const short& GetLocalWord(short nthWord) const;
- const long& GetLocalDoubleWord(short nthDoubleWord) const;
-
- Boolean LooksValid() const;
-
- Boolean operator==(const CStackFrame& stackFrame) const;
- Boolean operator!=(const CStackFrame& stackFrame) const;
- };
-
-
- //----------------------------------------------------------------------------------------
- // class CStackFrameIterator
- //----------------------------------------------------------------------------------------
-
- class CStackFrameIterator : public CIterator
- {
- private: // data fields
- CStackFrame fTopFrame;
- CStackFrame fCurrentFrame;
-
- public: // methods
- CStackFrameIterator(CStackFrame topFrame);
-
- virtual Boolean More();
- // Returns true if there are more frames to iterate over
-
- virtual void Reset();
- // Resets the iterator to begin again
-
- CStackFrame FirstFrame();
- // returns the first stack frame
-
- CStackFrame NextFrame();
- // increments and then returns the current stack frame
-
- protected: // methods
- virtual void Advance();
- // Advances the iteration
- };
-
-
- //----------------------------------------------------------------------------------------
- // Externally available global variables
- //----------------------------------------------------------------------------------------
-
- extern Boolean gHighLevelDebuggerRunning;
-
- #endif // qDebug
-
- //----------------------------------------------------------------------------------------
- // Externally available global flags for controlling printf info.
- //----------------------------------------------------------------------------------------
-
- #if qDebug
- extern Boolean gUserFlag1;
- extern Boolean gUserFlag2;
- extern Boolean gUserFlag3;
- extern Boolean gAssumeFocused;
- extern Boolean gDebugPrinting;
- extern Boolean gIntenseDebugging;
- extern Boolean gReportEvent;
- extern Boolean gReportMenuChoices;
- extern Boolean gShowCursorRegion;
- extern Boolean gShowHelpRegion;
- extern Boolean gShowInvalidations;
- extern Boolean gShowSleepRegion;
- extern Boolean gMemMgtBreak;
- extern Boolean gRsrcReport;
- extern Boolean gSegReport;
-
- // Debuggers <= kxNoDebugger don't have the ability to show debug messages in a console window
- // they use the AppleEvent hack for now
- #define kxMWDebug68K -2
- #define kxMWDebugPPC -1
- #define kxNoDebugger 0
- #define kxJasik 1
- #define kxSourceBug 2
- #define kxSade 3
- #define kxR2DbPPC 4
- #define kxR2Db68K 5
- #define kxVooDoo 6
-
- extern short gCurrentDebugger;
- #else
- const Boolean gUserFlag1 = FALSE;
- const Boolean gUserFlag2 = FALSE;
- const Boolean gUserFlag3 = FALSE;
- const Boolean gAssumeFocused = FALSE;
- const Boolean gDebugPrinting = FALSE;
- const Boolean gIntenseDebugging = FALSE;
- const Boolean gReportEvent = FALSE;
- const Boolean gReportMenuChoices = FALSE;
- const Boolean gShowCursorRegion = FALSE;
- const Boolean gShowHelpRegion = FALSE;
- const Boolean gShowInvalidations = FALSE;
- const Boolean gShowSleepRegion = FALSE;
- const Boolean gMemMgtBreak = FALSE;
- const Boolean gRsrcReport = FALSE;
- const Boolean gSegReport = FALSE;
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // Global function declarations
- //----------------------------------------------------------------------------------------
-
- #if qDebug | qTheDebugger
-
- extern void InitUDebug();
-
- #endif
-
-
- #if qDebug
-
- extern Boolean DebugCanReadLn();
- // Returns true if you can ReadLn to the user. This in turn is true when there is a
- // debug view (pDebugView), that view can currently write to its window, and this unit
- // is initialized.
-
- extern Boolean DebugCanWriteLn();
- // Returns true if you can WriteLn to the user in the debug window. This is true if
- // there exists a debug view and this unit is initialized.
-
- extern void DebugWriteLnHook(Ptr textBuf, long byteCount);
- // MacApp's bottleneck for writing debug output (not for general use).
-
- extern void EachFrameDo(CStackFrame baseFrame,
- DoToFrameType DoToFrame,
- void* yourDataPtr);
- // Recursive iterate up the stack frame calling DoToFrame for each frame.
-
- extern void GetCallersMethodName(MAName& s);
- // Return the name of the calling method in s.
-
- extern void GetMethodName(void* pc, MAName& s);
- // Returns in s the name of the method or procedure into which address ppc points.
- // Calls GetProcName to do the work.
-
- extern void GetProcName(void* pc, ClassName& className, MAName& procName);
- // Returns in procName the name of the method, procedure, or function into which
- // address ppc points. If it is a method, the method's class is returned in className.
- // If not a method, className is set to ''.
-
- extern void ShowSegments();
- // Write a list of the loaded segments out to the debugger.
-
- extern Boolean System6HasDebugger();
- // Check to see if Sade or SourceBug is running. This may not work in future systems,
- // so this should only be used under System 6.
-
- extern void ConfirmHighLevelDebugger();
- // Confirm that the high level debugger is still running.
-
- #endif // qDebug
-
- #endif // __UDEBUG__
-